﻿CMAKE_MINIMUM_REQUIRED(VERSION 3.10)

#项目名称
PROJECT(Test
	VERSION 	1.0.0.0
    DESCRIPTION "init")

include(../pc2/pc2.cmake)

#设置静态链接C运行库
PC2_MFC_SET("D"  FALSE)


#设置宏定义 
# -----------------------------------------------------------------------------



# -----------------------------------------------------------------------------
# 定义包含目录
# -----------------------------------------------------------------------------
INCLUDE_DIRECTORIES(
	${PROJECT_SOURCE_DIR}/
)

# -----------------------------------------------------------------------------
# 定义源目录
# -----------------------------------------------------------------------------
FILE(GLOB SRC_DIR1  "${PROJECT_SOURCE_DIR}/*.cpp"									"${PROJECT_SOURCE_DIR}/*.h" )
SET(MY_SOURCE_DIRECTORIES
	${SRC_DIR1}
	${PC2_SRC}
)
SOURCE_GROUP("SRC"		FILES	${SRC_DIR1})


# -----------------------------------------------------------------------------
# 不同平台的配置信息
# -----------------------------------------------------------------------------
if(PC2_OS MATCHES "windows_x86|windows_x64")
	#平台特定的文件
	#平台特定的文件:版本信息文件
	CONFIGURE_FILE(	"${PROJECT_SOURCE_DIR}/VERSION.rc.in" 
					"${PROJECT_BINARY_DIR}/VERSION.rc")
	SET(MY_SOURCE_OSFILES 	"${PROJECT_BINARY_DIR}/VERSION.rc")
	SOURCE_GROUP("RES" FILES ${MY_SOURCE_OSFILES})
	
	

elseif(PC2_OS MATCHES "linux_x64")
	#平台特定的文件:版本信息文件
	CONFIGURE_FILE(	"${PROJECT_SOURCE_DIR}/VERSION.rc.in" 
					"${PROJECT_BINARY_DIR}/VERSION.c")
	SET(MY_SOURCE_OSFILES 	"${PROJECT_BINARY_DIR}/VERSION.c")
	
	#编译参数
	SET(CMAKE_CXX_FLAGS "-w -fexceptions -fvisibility=hidden -fpermissive -fPIC")
	SET(CMAKE_C_FLAGS   "-fvisibility=hidden")
	
	#链接第三方库
	
	#链接参数
	LINK_LIBRARIES(pthread rt m dl g)
	
elseif(PC2_OS MATCHES "linux_aarch64")
	#平台特定的文件:版本信息文件
	CONFIGURE_FILE(	"${PROJECT_SOURCE_DIR}/VERSION.rc.in" 
					"${PROJECT_BINARY_DIR}/VERSION.c")
	SET(MY_SOURCE_OSFILES 	"${PROJECT_BINARY_DIR}/VERSION.c")
	
	#编译参数
	SET(CMAKE_CXX_FLAGS "-w -fexceptions -fvisibility=hidden -fpermissive -fPIC")
	SET(CMAKE_C_FLAGS   "-fvisibility=hidden")
	
	#链接第三方库
	
	#链接参数
	LINK_LIBRARIES(pthread rt m dl g)
	
elseif(PC2_OS MATCHES "android_armeabi-v7a")
	#平台特定的文件:版本信息文件
	CONFIGURE_FILE(	"${PROJECT_SOURCE_DIR}/VERSION.rc.in" 
					"${PROJECT_BINARY_DIR}/VERSION.c")
	SET(MY_SOURCE_OSFILES 	"${PROJECT_BINARY_DIR}/VERSION.c")
	
	#编译参数
	SET(CMAKE_CXX_FLAGS "-w -pie -fpermissive -fPIE -fvisibility=hidden")
	SET(CMAKE_C_FLAGS   "-w -pie -fpermissive -fPIE -fvisibility=hidden")
	
	#链接参数
	LINK_LIBRARIES(m dl)
else()
	MESSAGE(FATAL_ERROR "Unsupported Platform: '${PC2_OS}'")
endif()

# -----------------------------------------------------------------------------
# 设置编译后输出目录
# -----------------------------------------------------------------------------
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG 			${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG 			${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG  			${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE 			${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)       
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE 			${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE  		${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL 		${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)       
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL 		${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL  		${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO 	${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)       
	set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO 	${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
	set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO  	${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)    
else()
	SET(LIBRARY_OUTPUT_PATH 							${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)
	SET(EXECUTABLE_OUTPUT_PATH 							${PROJECT_SOURCE_DIR}/../bin_${PC2_OS}/)
endif()

# -----------------------------------------------------------------------------
# 开始编译。
# 编译可以执行文件：ADD_EXECUTABLE(${PROJECT_NAME}		${MY_SOURCE_DIRECTORIES})
# 编译动态库：		ADD_LIBRARY(${PROJECT_NAME} SHARED	${MY_SOURCE_DIRECTORIES})
# 编译静态库：		ADD_LIBRARY(${PROJECT_NAME} STATIC	${MY_SOURCE_DIRECTORIES})
# -----------------------------------------------------------------------------
ADD_EXECUTABLE(${PROJECT_NAME}		${MY_SOURCE_DIRECTORIES} ${MY_SOURCE_OSFILES})


#设置启动工程
SET_PROPERTY(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}	)